﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace Apollo.Modules.Common
{
    public class CommonModule : BaseModule
    {
        public const string ACTION_CHECK_USER_LDAP = "CHECK_USER_LDAP";

        public CommonModule() : base() { }

        public override void OnInit(Application app) {
            app.RegisterAction(ACTION_CHECK_USER_LDAP);
        }

        [Action(ACTION_CHECK_USER_LDAP, ActionHandlingType.Active)]
        public static ActionContext RedirectToCheckUserInLDAP(object obj) {
            UserCommon uc = obj as UserCommon;
            if (uc != null)
                HttpContext.Current.Response.Redirect("/CheckUserInLDAP.aspx?u=" + uc.Name);
            else
                return new ActionContext(new ActionMessage("Current object is not a user!", ActionMessageType.Error));

            return null;
        }
    }
}
